﻿///******************************************************    
///	FileName: UserEdit.js
///	Action: 前台会员信息修改页面JS处理文件
///	Copyright(c)  2004-2008 网胜科技公司技术开发部
///	Writer: XYF
///	Create Date: 2008-12-24
///	Rewriter:
///	Rewrite Date:
///****************************************************** 
var rightIcon="../../../images/websen.gif"
var rightIcons="../../../images/icon_nothing.gif";
var txtjbo=new  Array("ctl00_ContInfo_txtlinkName","ctl00_ContInfo_txtDepartment","ctl00_ContInfo_txtPosition","ctl00_ContInfo_txtMobilePhone" ,"ctl00_ContInfo_txtEmail")
var txtjbos=new Array("ctl00_ContInfo_txtlinkName","ctl00_ContInfo_txtDepartment","ctl00_ContInfo_txtPosition","ctl00_ContInfo_txtMobilePhone","ctl00_ContInfo_txtTel_DistrictNumber","ctl00_ContInfo_txtFax_DistrictNumber","ctl00_ContInfo_txtEmail","ctl00_ContInfo_txtQQ","ctl00_ContInfo_txtMSN")
window.onload=function(){ 
    //等到焦点
    for(var i=0;i<txtjbos.length;i++){ 
        $(txtjbos[i]).onfocus =function (){
            for (var j=0;j<txtjbos.length;j++){
                if (txtjbos[j]==event.srcElement.id){postobj(j);}
            }
        }
    }
    //失去焦点.replace(/\s/g,'')
    for(var i=0;i<txtjbos.length;i++){ 
        $(txtjbos[i]).onblur =function (){
            for (var j=0;j<txtjbos.length;j++){
                if (txtjbos[j]==event.srcElement.id){postobjs(j);}
            }
        }
    }
    //手机
    $("ctl00_ContInfo_txtMobilePhone").onchange =function (){ 
        return  txtMobilePhone();
    }
    $("ctl00_ContInfo_txtTel_DistrictNumber").onblur=function(){
        ob_txtTel_1234();
    }
    $("ctl00_ContInfo_txtTel_Telephone").onblur=function(){
        ob_txtTel_1234();
    }
    //邮箱
    $("ctl00_ContInfo_txtEmail").onblur=function(){
        txtEmail()
    }

}

function postobj(num){
    obj = "txt"+num;
    document.getElementById(obj).innerHTML =register[num];
}



function postobjs(num){
    var obj="txt"+num;
    if ($(obj).innerHTML!=""){
        $(obj).innerHTML=""
    }else {
        $(obj).innerHTML=ok;
    }
}

function oo(){
    $("yc").style.display="none"
}

function $(id){
    return document.getElementById(id)
}

function getobj(objName){
    if ($) {
        return eval('$("'+ objName +'")');
    }else {
        return eval('document.all["'+ objName +'"]');
    }
}

//提交 
$("ctl00_ContInfo_btnUpdate").onclick=function Server(){
    var UserEdit=new Array()
    UserEdit[0]=numbers($(txtjbos[0]),0)
    UserEdit[1]=numbers($(txtjbos[1]),1)
    UserEdit[2]=numbers($(txtjbos[2]),2)
    UserEdit[3]=txtMobilePhone()//手机
    UserEdit[4]=ob_txtTel_1234()//电话
    UserEdit[5]=Telefacsimile()//传真
    UserEdit[6]=txtEmail()//邮箱
    var flag=1;
    for (i=0;i<=6;i++){
        if (UserEdit[i]==false){
            flag=0;
            break;
        }
    } 
    if(flag==0)
        return false;
    else
        return true;
}

//判断空
function numbers(ID,num){
    var obj="txt"+num
    if (ID.value.replace(/\s/g,'')==""){
        document.getElementById(obj).innerHTML=YuXi[num];
        return false;
    }else {
        document.getElementById(obj).innerHTML=ok;
        return true;
    }
}

//电话
function ob_txtTel_1234() {
    if (($("ctl00_ContInfo_txtTel_Telephone").value.length == 7 || $("ctl00_ContInfo_txtTel_Telephone").value.length == 8) && $("ctl00_ContInfo_txtTel_International").value == "86" && ($("ctl00_ContInfo_txtTel_DistrictNumber").value.length == 3 || $("ctl00_ContInfo_txtTel_DistrictNumber").value.length == 4 || $("ctl00_ContInfo_txtTel_DistrictNumber").value.length == 5)) {
        $("txt4").innerHTML=ok;
        return true ;
    } else {
        $("txt4").innerHTML =YuXi[10];
        return false;
    }
}

//传真
function Telefacsimile(){
    var Fax1=$("ctl00_ContInfo_txtFax_International")
    var Fax2=$("ctl00_ContInfo_txtFax_DistrictNumber")
    var Fax3=$("ctl00_ContInfo_txtFax_Telephone")
    if (Fax1.value!=""&&Fax2.value!=""&&Fax3.value!=""){
        if(Fax1.value=="86"&&(Fax2.value.length==3||Fax2.value.length==4||Fax2.value.length==5)&&(Fax3.value.length==7||Fax3.value.length==8)){
            $("txt5").innerHTML=ok;
            return true
        } else{
            $("txt5").innerHTML=YuXi[14];
            return false
       }
    }else{
        $("txt5").innerHTML="";
        return true
   }
}

//手机
function txtMobilePhone(){
    if ($(txtjbos[3]).value.replace(/\s/g,'')==""){
        $("txt3").innerHTML=YuXi[3];
        return false
    }else if(!checkMobile($(txtjbos[3]).value.replace(/\s/g,''))){
        $("txt3").innerHTML=YuXi[9];
        return false
    }else{
        $("txt3").innerHTML=ok;
        return true
    }
}

//邮箱
function txtEmail(){
    if($(txtjbo[4]).value.replace(/\s/g,'')==""){
        $("txt6").innerHTML=YuXi[6]
        return false
    }else if(!ValidateEmail($(txtjbo[4]).value.replace(/\s/g,''))){
        $("txt6").innerHTML=YuXi[12]
        return false
    }else{
        $("txt6").innerHTML=ok
        return true
    }
}



//处理信息
var title="<p>";
var titles="</p>"
//显示信息会员修改
var register=new Array(8)
register[0]=title+"请输入真实的姓名"+titles
register[1]=title+"请输入你所在的部门"+titles
register[2]=title+"请输入你所担任的职位"+titles
register[3]=title+"格式如下:13*********"+titles
register[4]=title+"国家代码－区号－电话号码-分机(非必填)"+titles
register[5]=title+"请输入有效的传  真(非必填)"+titles
register[6]=title+"请输入你的真实的Email以便方便使用"+titles
register[7]=title+"请输入有效的QQ(非必填)"+titles
register[8]=title+"请输入有效的MSN(非必填)"+titles
var YuXi =new Array()
var XiuGai="<img src="+rightIcon+" align=\"absmiddle\"> <font color=#FF0000>"
YuXi[0]=XiuGai+"用户名不能为空，请重新设置用户名！</font>"
YuXi[1]=XiuGai+"部门不能为空，请重新设置用部门！</font>"
YuXi[2]=XiuGai+"职位不能为空，请重新设置用职位！</font>"
YuXi[3]=XiuGai+"手机不能为空，请重新设置用手机！</font>"
YuXi[4]=XiuGai+"电话不能为空，请重新设置用电话！</font>"
YuXi[5]=""
YuXi[6]=XiuGai+"邮箱不能为空，请重新设置用邮箱！</font>"
YuXi[7]=""
YuXi[8]=""
YuXi[9]=XiuGai+"手机输入有误，请重新设置用手机！</font>"
YuXi[10]=XiuGai+"电话输入有误，请重新设置用电话！</font>"
YuXi[11]=XiuGai+"邮箱重名,请重新设置邮箱!</font>"
YuXi[12]=XiuGai+"输入不符合规范 格式如下:b2b@websen.com！</font>"
YuXi[13]=XiuGai+"确认MSN输入有误,请重新设置MSN!</font>"
YuXi[14]=XiuGai+"确认传真输入有误，请重新设置传真！<font>"
var ok="<font color=#999999>输入符合规范</font>";
